package com.js.signin.controller;

import com.js.signin.entity.Student;
import com.js.signin.pojo.StudentAssist;
import com.js.signin.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class StudentController {

    @Autowired
    private StudentService studentService;


    @GetMapping("/selectAllIT")
    public String selectAllIT(Model model){
        List<Student> list = studentService.selectAllIT();
        int count = studentService.selectCountIT();
        model.addAttribute("count",count);
        model.addAttribute("list",list);
        return "list";
    }

    @GetMapping("/selectAllJAVA")
    public String selectAllJAVA(Model model){
        List<Student> list = studentService.selectAllJAVA();
        int count = studentService.selectCountJava();
        model.addAttribute("count",count);
        model.addAttribute("list",list);
        return "list";
    }

    @PostMapping("/add")
    @ResponseBody
    public int add(Student student){
        int result = studentService.SignIn(student);
        return result;
    }

}
